function formatTime(date) {
  var year = date.getFullYear()
  var month = date.getMonth() + 1
  var day = date.getDate()

  var hour = date.getHours()
  var minute = date.getMinutes()
  var second = date.getSeconds()


  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

function formatNumber(n) {
  n = n.toString()
  return n[1] ? n : '0' + n
}
//提取网点联系电话
function telephone(tel) {
  var s = "";
  for (var i = 0; i < tel.length; i++) {
    if ("0123456789-、，/".indexOf(tel.substr(i, 1)) > -1)
      s += tel.substr(i, 1);
  }
  return s.split(/[\/，|、]/);
  //return s.split("、|，");
}

function throttle(func, wait) {

  let previous = 0;

  return function () {
    let now = +new Date();
    let context = this;

    if (now - previous >= wait) {
      func.apply(context, arguments);
      previous = now; // 执行后更新 previous 值
    }
  }
}

module.exports = {
  formatTime: formatTime,
  throttle: throttle
}
